package artid.com.arttogo.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import java.util.List;

import artid.com.arttogo.R;
import artid.com.arttogo.bean.DotPraiseUserParser;
import artid.com.arttogo.utils.MyBitmapImageViewTarget;
import artid.com.arttogo.view.CircleImageView;

/**
 * 
*    
* 项目名称：ArtworkArt   
* 类名称：DotPraiseUser_Adapter   
* 类描述：点赞用户适配器   
* 创建人：耿卫斌   
* 创建时间：2017-1-18 上午11:11:09   
*
 */
public class DotPraiseUser_Adapter extends BaseAdapter {
	private Context mContext;
	private List<DotPraiseUserParser> list;

	public DotPraiseUser_Adapter(Context mContext,
								 List<DotPraiseUserParser> list) {
		super();
		this.mContext = mContext;
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder = null;
		View v = convertView;
		if (v == null) {
			holder = new ViewHolder();
			v = LayoutInflater.from(mContext).inflate(R.layout.item_dotpraiseuser, null);
			holder.head_img=(CircleImageView) v.findViewById(R.id.item_dotpraiseuser_headimg);
			holder.name=(TextView) v.findViewById(R.id.item_dotpraiseuser_name);
			v.setTag(holder);
		} else {
			holder = (ViewHolder) v.getTag();
		}
		Glide.with(mContext).load(list.get(position).getImgurl()).asBitmap().centerCrop()
		.placeholder(R.drawable.ic_menu_rotate).error(R.drawable.ic_menu_rotate)
		.into(new MyBitmapImageViewTarget(holder.head_img));
		holder.name.setText(list.get(position).getRealname());
		return v;
	}
	class ViewHolder {
		CircleImageView head_img;
		TextView name;
	}
}
